package com.newtouch.bxzs.business.message.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.newtouch.bxzs.common.base.model.Announcement;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * 公告管理的mapper类
 *
 * <p>
 * <b>History:</b>
 * <table border="1">
 * <tr>
 * <th>Date</th>
 * <th>Operator</th>
 * <th>Memo</th>
 * </tr>
 * <tr>
 * <td>2020/12/23</td>
 * <td>liman</td>
 * <td>Create</td>
 * </tr>
 * </table>
 *
 * @author liman
 * @version 1.0.0
 * @since 1.0.0
 */

@Mapper
public interface AnnouncementMapper extends BaseMapper<Announcement> {
    /**
     * 统计用户未读通知条数（已发布的）
     * @param userId 用户id
     * @return 未读通知条数
     */
    @Select("SELECT count(*) FROM ASSISTANT_NOTIFICATION_USER_MAP a LEFT JOIN ASSISTANT_NOTIFICATION b ON a.NOTIFICATION_ID = b.NOTIFICATION_ID\n" +
            "WHERE a.USER_ID = #{userId} AND a.IS_DELETE = 0 \n" +
            "AND a.IS_READ = 0 AND b.PUBLISH_STATUS = '2'")
    Integer countUserUnReadNumber(String userId);
}
